home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / circuits / spice2g6.z / spice2g6 / spice / Fortran / acan.f next >
Encoding:
Text File  |  1989-02-03  |  5.2 KB  |  162 lines

  1. c spice version 2g.6  sccsid=acan.ma 3/15/83
  2.       subroutine acan
  3.       implicit double precision (a-h,o-z)
  4. c
  5. c     this routine drives the small-signal analyses.
  6. c
  7. c spice version 2g.6  sccsid=tabinf 3/15/83
  8.       common /tabinf/ ielmnt,isbckt,nsbckt,iunsat,nunsat,itemps,numtem,
  9.      1   isens,nsens,ifour,nfour,ifield,icode,idelim,icolum,insize,
  10.      2   junode,lsbkpt,numbkp,iorder,jmnode,iur,iuc,ilc,ilr,numoff,isr,
  11.      3   nmoffc,iseq,iseq1,neqn,nodevs,ndiag,iswap,iequa,macins,lvnim1,
  12.      4   lx0,lvn,lynl,lyu,lyl,lx1,lx2,lx3,lx4,lx5,lx6,lx7,ld0,ld1,ltd,
  13.      5   imynl,imvn,lcvn,nsnod,nsmat,nsval,icnod,icmat,icval,
  14.      6   loutpt,lpol,lzer,irswpf,irswpr,icswpf,icswpr,irpt,jcpt,
  15.      7   irowno,jcolno,nttbr,nttar,lvntmp
  16. c spice version 2g.6  sccsid=miscel 3/15/83
  17.       common /miscel/ atime,aprog(3),adate,atitle(10),defl,defw,defad,
  18.      1  defas,rstats(50),iwidth,lwidth,nopage
  19. c spice version 2g.6  sccsid=cirdat 3/15/83
  20.       common /cirdat/ locate(50),jelcnt(50),nunods,ncnods,numnod,nstop,
  21.      1   nut,nlt,nxtrm,ndist,ntlin,ibr,numvs,numalt,numcyc
  22. c spice version 2g.6  sccsid=status 3/15/83
  23.       common /status/ omega,time,delta,delold(7),ag(7),vt,xni,egfet,
  24.      1   xmu,sfactr,mode,modedc,icalc,initf,method,iord,maxord,noncon,
  25.      2   iterno,itemno,nosolv,modac,ipiv,ivmflg,ipostp,iscrch,iofile
  26. c spice version 2g.6  sccsid=flags 3/15/83
  27.       common /flags/ iprnta,iprntl,iprntm,iprntn,iprnto,limtim,limpts,
  28.      1   lvlcod,lvltim,itl1,itl2,itl3,itl4,itl5,itl6,igoof,nogo,keof
  29. c spice version 2g.6  sccsid=knstnt 3/15/83
  30.       common /knstnt/ twopi,xlog2,xlog10,root2,rad,boltz,charge,ctok,
  31.      1   gmin,reltol,abstol,vntol,trtol,chgtol,eps0,epssil,epsox,
  32.      2   pivtol,pivrel
  33. c spice version 2g.6  sccsid=ac 3/15/83
  34.       common /ac/ fstart,fstop,fincr,skw2,refprl,spw2,jacflg,idfreq,
  35.      1   inoise,nosprt,nosout,nosin,idist,idprt
  36. c spice version 2g.6  sccsid=cje 3/15/83
  37.       common /cje/ maxtim,itime,icost
  38. c spice version 2g.6  sccsid=blank 3/15/83
  39.       common /blank/ value(200000)
  40.       integer nodplc(64)
  41.       complex cvalue(32)
  42.       complex cendor
  43.       equivalence (value(1),nodplc(1),cvalue(1))
  44.       call second(t1)
  45. c.. post-processor initialization
  46.       if(ipostp.eq.0) go to 1
  47.       numcur=jelcnt(9)
  48.       numpos=nunods+numcur
  49.       call getm16(ibuff,numpos)
  50.       numpos=numpos*4
  51.       if(numcur.eq.0) go to 1
  52.       loc=locate(9)
  53.       loccur=nodplc(loc+6)-1
  54. c
  55. c  allocate storage
  56. c
  57.     1 call getm8(ndiag,2*nstop)
  58.       call getm8(lvn,nstop+nttbr)
  59.       call getm8(imvn,nstop+nttbr)
  60.       call getm16(lcvn,nstop)
  61.       if (idist.ne.0) call dinit
  62.       nandd=0
  63.       if (inoise.eq.0) go to 10
  64.       if (idist.eq.0) go to 10
  65.       nandd=1
  66.       call getm16(lvntmp,nstop)
  67.    10 call getm16(loutpt,0)
  68.       call crunch
  69.       numout=jelcnt(43)+jelcnt(44)+jelcnt(45)+1
  70.       lynl=lvn
  71.       imynl=imvn
  72.       lcvntp=lvntmp
  73.       icalc=0
  74.       if (ipostp.ne.0) call pheadr(atitle)
  75.       freq=fstart
  76. c
  77. c  load y matrix and c vector, solve for v vector
  78. c
  79.   100 call getcje
  80.       if ((maxtim-itime).le.limtim) go to 900
  81.       omega=twopi*freq
  82.       call acload
  83.   110 call acdcmp
  84.       call acsol
  85.       if (igoof.eq.0) go to 200
  86.       write (iofile,121) igoof,freq
  87.   121 format('0warning:  underflow ',i4,' time(s) in ac analysis at freq
  88.      1 = ',1pd9.3,' hz')
  89.       igoof=0
  90. c
  91. c  store outputs
  92. c
  93.   200 call extmem(loutpt,numout)
  94.       loco=loutpt+icalc*numout
  95.       icalc=icalc+1
  96.       cvalue(loco+1)=cmplx(sngl(freq),sngl(omega))
  97.       loc=locate(43)
  98.   310 if (loc.eq.0) go to 350
  99.       if (nodplc(loc+5).ne.0) go to 320
  100.       node1=nodplc(loc+2)
  101.       node2=nodplc(loc+3)
  102.       iseq=nodplc(loc+4)
  103.       cvalue(loco+iseq)=cvalue(lcvn+node1)-cvalue(lcvn+node2)
  104.       loc=nodplc(loc)
  105.       go to 310
  106.   320 iptr=nodplc(loc+2)
  107.       iptr=nodplc(iptr+6)
  108.       iseq=nodplc(loc+4)
  109.       cvalue(loco+iseq)=cvalue(lcvn+iptr)
  110.       loc=nodplc(loc)
  111.       go to 310
  112.   350 if(ipostp.eq.0) go to 400
  113.       cvalue(ibuff+1)=cmplx(sngl(freq),0.0e0)
  114.       call copy16(cvalue(lcvn+2),cvalue(ibuff+2),nunods-1)
  115.       if(numcur.ne.0) call copy16(cvalue(lcvn+loccur+1),
  116.      1  cvalue(ibuff+nunods+1),numcur)
  117.       call dblsgl(cvalue(ibuff+1),numpos)
  118.       call fwrite(cvalue(ibuff+1),numpos)
  119. c
  120. c  noise and distortion analyses
  121. c
  122.   400 if (nandd.eq.0) go to 410
  123.       call copy16(cvalue(lcvn+1),cvalue(lcvntp+1),nstop)
  124.   410 if (inoise.ne.0) call noise(loco)
  125.       if (nandd.eq.0) go to 420
  126.       call copy16(cvalue(lcvntp+1),cvalue(lcvn+1),nstop)
  127.   420 if (idist.ne.0) call disto(loco)
  128. c
  129. c  increment frequency
  130. c
  131.       if (icalc.ge.jacflg) go to 1000
  132.       if (idfreq.ge.3) go to 510
  133.       freq=freq*fincr
  134.       go to 100
  135.   510 freq=freq+fincr
  136.       go to 100
  137. c
  138. c  finished
  139. c
  140.   900 write (iofile,901)
  141.   901 format('0*error*:  cpu time limit exceeded ... analysis stopped'/)
  142.       nogo=1
  143.  1000 if(ipostp.eq.0) go to 1010
  144.       if (ipostp.ne.0) call clsraw
  145.       if(ipostp.ne.0) call clrmem(ibuff)
  146.  1010 call clrmem(lvnim1)
  147.       call clrmem(lx0)
  148.       call clrmem(lvn)
  149.       call clrmem(imvn)
  150.       call clrmem(lcvn)
  151.       call clrmem(ndiag)
  152.       if (idist.eq.0) go to 1020
  153.       call clrmem(ld0)
  154.       call clrmem(ld1)
  155.  1020 if (nandd.eq.0) go to 1040
  156.       call clrmem(lvntmp)
  157.  1040 call second(t2)
  158.       rstats(7)=rstats(7)+t2-t1
  159.       rstats(8)=rstats(8)+icalc
  160.       return
  161.       end
  162.